/****************************************************************
irrEventManager
Copyright (C) 2007-2008 Keith Holbrook
This file is part of "irrEventManager".
For conditions of distribution and use, see copyright notice in irrEventManagerr.h

*****************************************************************/

#ifndef IEVENTMANAGER_H
#define IEVENTMANAGER_H

#include "eventmancfg.h"
#include "IReferenceCounted.h"
#include "IEventReceiver.h"
#include "IEventEx.h"


namespace irr
{

    class IEventManager :  public IEventReceiver, public virtual IReferenceCounted
    {
    public:

        virtual ~IEventManager() {}

        //!need to call update() at end of your run loop
        /**for the mouseClick() ,mouseUp() ,keyClick() and keyUp() functions to work properly. */
        virtual  void update()=0;

        virtual void removeAll()=0;

        //!dispatches events
        virtual bool OnEvent(const SEvent&)=0;


        //!returns delay time for getChar() (see getChar())
        virtual  u32  keyDelay()=0;

        //! sets delay time for getChar() (see getChar())
        virtual void setKeyDelay(const u32)=0;

       //!returns current (wide)character pressed.
	   /**There is a built-in delay so the char will only be returned
	    once until that time is reached. (Zero is returned instead)*/
        virtual wchar_t keyChar()=0;

	    //!returns true if key is presssed down false if not.
        virtual bool keyDown(EKEY_CODE)=0;


	    //!returns true ONLY ONCE PER KEY PRESS if key is presssed down.
        /**need to reset with update() to get more than 1 true per loop*/
        virtual bool keyClick(EKEY_CODE)=0;

        //!returns true if any key is pressed. Zero if no keys pressed.
        virtual s32 anyKeydown()=0;

        //!returns key code of last key up.
        /**need to reset with update()*/
        virtual EKEY_CODE keyUp()=0;

        //!	return:  mouse Position
        virtual const  core::position2d<s32>& mousePos()=0;

        //!return  mouse wheel  (-1,or 1)
        virtual f32 mouseWheel() =0;

        //!return  mouse down:
        /** true if down,false if up*/
        virtual bool mouseDown(EMOUSE_BUTTONS)=0;

        //!returns true only once per press
        /**need to reset with update() to get more than 1 true per loop*/
        virtual bool mouseClick(EMOUSE_BUTTONS)=0;

        //!return  true if mouse button up;
        /**need to reset with update()*/
        virtual  bool  mouseUp(EMOUSE_BUTTONS)=0;


        //!get Events
        /**see IEvent.h*/


       //!return: Key event
       //!the default startId of 999 returns the first id at 1000
        virtual  IEventEx* getKeyEvent(s32 startId=999) =0;

        //!return: Mouse event
        virtual  IEventEx* getMouseEvent(s32 startId=999) =0;

        //!return: Gui event determined by EEVENT_HANDLER_TYPE argument.
        /**startId : ids start at 1000 unless set here*/
        virtual  IEventEx* getGuiEvent(gui::EGUI_EVENT_TYPE,s32 startId=999) =0;

        //!return: User event
        virtual  IEventEx* getUserEvent(s32 startId=999) =0;

        //!return: Log event
        virtual  IEventEx* getLogEvent(s32 startId=999) =0;

         //!return: Joy event
        virtual  IEventEx* getJoyEvent(s32 startId=999)=0;

         //!get any event
        //!to get a gui event you need to supply the gui event type
        //!the default id of 999 returns the first id at 1000
        //!if you want to manually set the start id for other  than a gui event,the guitype arg is ignored
        //! so just pass EGET_ELEMENT_FOCUS_LOST or (gui::EGUI_EVENT_TYPE)0
        //! for the guitype
        virtual  IEventEx* getEvent(EEVENT_TYPE,gui::EGUI_EVENT_TYPE guitype=gui::EGET_ELEMENT_FOCUS_LOST,s32 startId=999) =0;


        //!allows removing all receivers by data
        virtual void removeAllReceiversByData(void*)=0;

        //!allows removing all receivers by object
        virtual void removeAllReceiversByObject(void*)=0;

        //!allows removing all Gui receivers by the Data member
        virtual void removeAllGuiReceiversByData(void*)=0;

        //!allows removing all Gui receivers by caller(IGUIElement*)
        virtual void removeAllGuiReceiversByCaller(void*)=0;

        //!allows removing all Gui receivers by Object)
        virtual void removeAllGuiReceiversByObject(void*)=0;

        //!gets total receiver count from all events
        virtual u32 getReceiverCount()=0;


    };

}



#endif // IINPUTMANAGER_H


